package org.jchains.receiver.gui;

import javax.swing.table.AbstractTableModel;

import org.jchains.CORBA.PermissionTransferPackage.EnvironmentEntry;

public class EnvTableModel extends AbstractTableModel {
	
	EnvironmentEntry[] ee;
	
	public EnvTableModel(EnvironmentEntry[] _ee) {
		this.ee = _ee;
	}

	public int getColumnCount() {
		if (ee != null) {
			return 2;
		}
		return 0;

	}

	public int getRowCount() {
		if (ee != null) {
			return ee.length;
		}
		return 0;

	}

	public Object getValueAt(int rowIndex, int columnIndex) {
		if (ee == null || ee.length == 0)
			return null;

		if (ee.length < rowIndex)
			return null;

		if (columnIndex == 0)
			return ee[rowIndex].theKey;

		return ee[rowIndex].theValue;

	}

	String[] names = new String[] { "Key", "Value" };

	public String getColumnName(int column) {

		return names[column];
	}

}
